package Tests
import org.scalatest.FunSuite
import ru.mipt.board.net._
/**
 * Created by IntelliJ IDEA.
 * User: IL
 * Date: 18.09.2010
 * Time: 21:16:48
 * To change this template use File | Settings | File Templates.
 */

class BoardLoaderTest extends FunSuite{  //TODO probably should remove magic numbers
    test("when given negative id should throw exception"){
        var sucses = false
        try{
            val loader = new BoardLoader
            val result = loader parseThread  ( -4)
        }
        catch {
            case _ => sucses = true
        }
        assert( sucses  )
    }

    test("should return empty list if message doesn't exist"){
        val loader = new BoardLoader
        val result = loader parseThread( 445193)
        assert (result.size === 0)
    }

    test("message structer"){
        val loader = new BoardLoader
        val result = loader parseThread( 6713814)
        assert(result head  match{
            case BoardMessage(6713881,"QDiesel","",6713814,Some(6713828),"[Temp]понабежало школоты с двачей.") => true
            case _ => false
        })
    }

    test("test parsing of some thread"){
        val loader = new BoardLoader
        val result = loader parseThread( 6713814)
        val text  = result.filter(p=> ( ! p.text.isEmpty))
        assert (result.size === 13)
        assert(text.head.text === "плохой знак" )
    }

}